﻿using System;
using System.Collections.Generic;
using System.Net.NetworkInformation;
using System.Text;

namespace XHXTools
{
    /// <summary>
    /// ping地址
    /// </summary>
    public class PingClass
    {
        /// <summary>
        /// 是否链接正常
        /// </summary>
        /// <param name="url">ip地址或者域名</param>
        /// <returns>连通正常：true，反之：false</returns>
        public static bool IsPing(string url)
        {
            Ping pingSender = new Ping();
            try
            {
                PingReply reply = pingSender.Send(url);//第一个参数为ip地址，第二个参数为ping的时间
                if (reply.Status == IPStatus.Success)
                {
                    return true;
                }
                return false;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
